package com.yumis.service.common.advice;

import com.yumis.service.common.exception.GlobalException;
import com.yumis.service.common.vo.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @描述: 自定义异常处理
 */
@Slf4j
@ControllerAdvice
public class BasicExceptionHandler {

    @ExceptionHandler(GlobalException.class)
    public ResponseEntity<Response> handleException(GlobalException e) {
        return ResponseEntity.status(HttpStatus.OK).body(e.getResponse());
    }

}
